package vip.sweet.biz.modular.user.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vip.sweet.biz.modular.user.entity.BizUserAddresses;
import vip.sweet.biz.modular.user.mapper.BizUserAddressesMapper;
import vip.sweet.biz.modular.user.params.BizUserAddressAddParams;
import vip.sweet.biz.modular.user.service.BizUserAddressesService;

import java.util.List;

/**
 * @author ASUS
 * @Date 2025/10/5 12:04
 * @Descripition
 */
@Service
public class BizUserAddressesServiceImpl extends ServiceImpl<BizUserAddressesMapper, BizUserAddresses> implements BizUserAddressesService {
    @Override
    public boolean add(BizUserAddressAddParams bizUserAddressAddParams) {
        if (ObjectUtil.isNotEmpty(bizUserAddressAddParams))
            return save(BeanUtil.toBean(bizUserAddressAddParams, BizUserAddresses.class));
        return false;
    }

    @Override
    public List<BizUserAddresses> getCustomerAddressById(String userId) {
        LambdaQueryWrapper<BizUserAddresses> queryWrapper=new LambdaQueryWrapper<>();
        if (ObjectUtil.isNotEmpty(userId))
            queryWrapper.eq(BizUserAddresses::getUserId,userId);
        return baseMapper.selectList(queryWrapper);
    }
}
